<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace plugins\sms_account\model; //Demo插件英文名，改成你的插件英文就行了
use think\Model;
use traits\model\SoftDelete;

//Demo插件英文名，改成你的插件英文就行了,插件数据表最好加个plugin前缀再加表名,这个类就是对应“表前缀+plugin_demo”表
class SmsAccountModel extends Model
{
    // 自动更新时间
    protected $autoWriteTimestamp = true;

    // 软删除
    use SoftDelete;
    protected $deleteTime = 'delete_time';


    /**
     * [验证账号信息]
     * @param  string $sms_uid      [短信用户id]
     * @param  string $sms_account  [短信用户帐号]
     * @return array [当前账号信息]
     */
    public static function verifyAccount($sms_uid="", $sms_account="")
    {
        if(empty($sms_uid) || empty($sms_account)){
            return zy_array(false,'参数不能为空！');
        }
        $where = ['uid'=>$sms_uid,'account'=>$sms_account];
        $info = self::where($where)->find();

        if (empty($info)) return zy_array(false,'无此账号！');
        if ($info['total_num']<=$info['consume_num']) return zy_array(false,'短信条数不足，请充值！');
        if ($info['total_num']-$info['consume_num'] < 20 ) $result['hint'] = '短信条数不足20条，请及时充值！';

        $result = $info;
        return zy_array(true,'操作成功！',$result);
    }



}
